<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns information on the current handler, the number of cache entries and cache entries, if available</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mysqlnd-qc-get-cache-info" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqlnd_qc_get_cache_info</h1>
  <p class="verinfo">(PECL mysqlnd_qc &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">mysqlnd_qc_get_cache_info</span> &mdash; <span class="dc-title">Returns information on the current handler, the number of cache entries and cache entries, if available</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mysqlnd-qc-get-cache-info-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   
   <span class="methodname"><strong>mysqlnd_qc_get_cache_info</strong></span>
    ( <span class="methodparam">void</span>
   ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">

  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysqlnd-qc-get-cache-info-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysqlnd-qc-get-cache-info-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns information on the current handler, the number of cache entries and
   cache entries, if available. If and what data will be returned for the cache
   entries is subject to the active storage handler.
   Storage handler are free to return any data. Storage handler are
   recommended to return at least the data provided by the default handler,
   if technically possible.
  </p>
  <p class="para">
   The scope of the information is the PHP process. Depending on the PHP deployment
   model a process may serve one or more web requests.
  </p>
  <p class="para">
   Values are aggregated for all cache activities on a per storage handler basis.
   It is not possible to tell how much queries originating from
   <em>mysqli</em>, <em>PDO_MySQL</em> or
   <em>mysql</em>.API calls have contributed to the aggregated data values. Use
   <span class="function"><a href="mysqlnd_qc_get_core_stats.html" class="function">mysqlnd_qc_get_core_stats()</a></span>
   to get timing data aggregated for all storage handlers.
  </p>
  <p class="para">
   Array of cache information
  </p>
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">handler</code>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       The active storage handler.
      </p>
      <p class="para">
       All storage handler. Since 1.0.0.
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">handler_version</code>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       The version of the active storage handler.
      </p>
      <p class="para">
       All storage handler. Since 1.0.0.
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">num_entries</code>
      <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
     </dt>

     <dd>

      <p class="para">
       The number of cache entries. The value depends on the storage handler in use.
      </p>
      <p class="para">
       The default, APC and SQLite storage handler provide the actual
       number of cache entries.
      </p>
      <p class="para">
       The MEMCACHE storage handler always returns <em>0</em>.
       MEMCACHE does not support counting the number of cache entries.
      </p>
      <p class="para">
       If a user defined handler is used, the number of
       entries of the <em>data</em> property is reported.
      </p>
      <p class="para">
       Since 1.0.0.
      </p>
     </dd>

    
    
     <dt>

      <code class="parameter">data</code>
      <span class="type"><a href="language.types.array.html" class="type array">array</a></span>
     </dt>

     <dd>

      <p class="para">
       The version of the active storage handler.
      </p>
      <p class="para">
       Additional storage handler dependent data on the cache entries.
       Storage handler are requested to provide similar and comparable
       information. A user defined storage handler is free to return any data.
      </p>
      <p class="para">
       Since 1.0.0.
      </p>
      <p class="para">
       The following information is provided by the default storage handler
       for the <em>data</em> property.
      </p>
      <p class="para">
       The <em>data</em>
       property holds a hash. The hash is indexed by the internal
       cache entry identifier of the storage handler. The cache entry identifier
       is human-readable and contains the query string leading to the cache entry.
       Please, see also the example below. The following data is given for
       every cache entry.
      </p>
      <p class="para">
       <dl>

        
         <dt>

          <code class="parameter">statistics</code>
          <span class="type"><a href="language.types.array.html" class="type array">array</a></span>
         </dt>

         <dd>

          <p class="para">
           Statistics of the cache entry.
          </p>
          <p class="para">
            Since 1.0.0.
          </p>
          <table class="doctable informaltable">
           
            <col width="1*" />
            <col width="7*" />
            <col width="2*" />
            <thead>
             <tr>
              <th>Property</th>
              <th>Description</th>
              <th>Version</th>
             </tr>

            </thead>

            <tbody class="tbody">
             <tr>
              <td>
               <em>rows</em>
              </td>
              <td>
               Number of rows of the cached result set.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>stored_size</em>
              </td>
              <td>
               The size of the cached result set in bytes. This is the size
               of the payload. The value is not suited for calculating the
               total memory consumption of all cache entries including the
               administrative overhead of the cache entries.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>cache_hits</em>
              </td>
              <td>
               How often the cached entry has been returned.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>run_time</em>
              </td>
              <td>
               Run time of the statement to which the cache entry belongs.
               This is the run time of the uncached statement. It is the time
               between sending the statement to MySQL receiving a reply from MySQL.
               Run time saved by using the query cache plugin can be calculated
               like this: <em>cache_hits * ((run_time - avg_run_time) + (store_time - avg_store_time))</em>.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>store_time</em>
              </td>
              <td>
               Store time of the statements result set to which the cache entry belongs.
               This is the time it took to fetch and store the results of the uncached
               statement.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>min_run_time</em>
              </td>
              <td>
               Minimum run time of the cached statement. How long it took
               to find the statement in the cache.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>min_store_time</em>
              </td>
              <td>
               Minimum store time of the cached statement. The time taken
               for fetching the cached result set from the storage medium and
               decoding
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>avg_run_time</em>
              </td>
              <td>
               Average run time of the cached statement.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>avg_store_time</em>
              </td>
              <td>
               Average store time of the cached statement.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>max_run_time</em>
              </td>
              <td>
               Average run time of the cached statement.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>max_store_time</em>
              </td>
              <td>
               Average store time of the cached statement.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>valid_until</em>
              </td>
              <td>
               Timestamp when the cache entry expires.
              </td>
              <td>Since 1.1.0.</td>
             </tr>

            </tbody>
           
          </table>

         </dd>

        
        
         <dt>

          <code class="parameter">metadata</code>
          <span class="type"><a href="language.types.array.html" class="type array">array</a></span>
         </dt>

         <dd>

          <p class="para">
           Metadata of the cache entry.
           This is the metadata provided by MySQL together with the
           result set of the statement in question. Different versions
           of the MySQL server may return different metadata. Unlike with
           some of the PHP MySQL extensions no attempt is made to hide
           MySQL server version dependencies and version details from the
           caller. Please, refer to the MySQL C API documentation that
           belongs to the MySQL server in use for further details.
          </p>
          <p class="para">
           The metadata list contains one entry for every column.
          </p>
          <p class="para">
            Since 1.0.0.
          </p>
          <table class="doctable informaltable">
           
            <col width="1*" />
            <col width="7*" />
            <col width="2*" />
            <thead>
             <tr>
              <th>Property</th>
              <th>Description</th>
              <th>Version</th>
             </tr>

            </thead>

            <tbody class="tbody">
             <tr>
              <td>
               <em>name</em>
              </td>
              <td>
               The field name. Depending on the MySQL version this
               may be the fields alias name.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>org_name</em>
              </td>
              <td>
               The field name.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>table</em>
              </td>
              <td>
               The table name. If an alias name was used for the table, this
               usually holds the alias name.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>org_table</em>
              </td>
              <td>
               The table name.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>db</em>
              </td>
              <td>
               The database/schema name.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>max_length</em>
              </td>
              <td>
               The maximum width of the field. Details may vary by MySQL server version.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>length</em>
              </td>
              <td>
               The width of the field. Details may vary by MySQL server version.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

             <tr>
              <td>
               <em>type</em>
              </td>
              <td>
               The data type of the field. Details may vary by the MySQL server in use.
               This is the MySQL C API type constants value. It is recommended
               to use type constants provided by the <em>mysqli</em> extension
               to test for its meaning. You should not test for certain type values
               by comparing with certain numbers.
              </td>
              <td>Since 1.0.0.</td>
             </tr>

            </tbody>
           
          </table>

         </dd>

        
       </dl>

      </p>
      <p class="para">
       The APC storage handler returns the same information
       for the <em>data</em> property but no <em>metadata</em>.
       The <em>metadata</em> of a cache entry is set to <em>NULL</em>.
      </p>
      <p class="para">
       The MEMCACHE storage handler does not fill the <em>data</em> property.
       Statistics are not available on a per cache entry basis with the MEMCACHE storage
       handler.
      </p>
      <p class="para">
       A user defined storage handler is free to provide any data.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mysqlnd-qc-get-cache-info-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2295">
   <p><strong>Example #1 <span class="function"><strong>mysqlnd_qc_get_cache_info()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    The example shows the output from the built-in default storage handler.
    Other storage handler may report different data.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Populate&nbsp;the&nbsp;cache,&nbsp;e.g.&nbsp;using&nbsp;mysqli&nbsp;*/<br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"host"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"schema"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"/*"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"*/SELECT&nbsp;id&nbsp;FROM&nbsp;test"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Display&nbsp;cache&nbsp;information&nbsp;*/<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">mysqlnd_qc_get_cache_info</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
 [&quot;num_entries&quot;]=&gt;
 int(1)
 [&quot;handler&quot;]=&gt;
 string(7) &quot;default&quot;
 [&quot;handler_version&quot;]=&gt;
 string(5) &quot;1.0.0&quot;
 [&quot;data&quot;]=&gt;
 array(1) {
   [&quot;Localhost via UNIX socket 3306 user schema|/*qc=on*/SELECT id FROM test&quot;]=&gt;
   array(2) {
     [&quot;statistics&quot;]=&gt;
     array(11) {
       [&quot;rows&quot;]=&gt;
       int(6)
       [&quot;stored_size&quot;]=&gt;
       int(101)
       [&quot;cache_hits&quot;]=&gt;
       int(0)
       [&quot;run_time&quot;]=&gt;
       int(471)
       [&quot;store_time&quot;]=&gt;
       int(27)
       [&quot;min_run_time&quot;]=&gt;
       int(0)
       [&quot;max_run_time&quot;]=&gt;
       int(0)
       [&quot;min_store_time&quot;]=&gt;
       int(0)
       [&quot;max_store_time&quot;]=&gt;
       int(0)
       [&quot;avg_run_time&quot;]=&gt;
       int(0)
       [&quot;avg_store_time&quot;]=&gt;
       int(0)
     }
     [&quot;metadata&quot;]=&gt;
     array(1) {
       [0]=&gt;
       array(8) {
         [&quot;name&quot;]=&gt;
         string(2) &quot;id&quot;
         [&quot;orig_name&quot;]=&gt;
         string(2) &quot;id&quot;
         [&quot;table&quot;]=&gt;
         string(4) &quot;test&quot;
         [&quot;orig_table&quot;]=&gt;
         string(4) &quot;test&quot;
         [&quot;db&quot;]=&gt;
         string(4) &quot;schema&quot;
         [&quot;max_length&quot;]=&gt;
         int(1)
         [&quot;length&quot;]=&gt;
         int(11)
         [&quot;type&quot;]=&gt;
         int(3)
       }
     }
   }
 }
}

</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysqlnd-qc-get-cache-info-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">
     <span class="function"><a href="mysqlnd_qc_get_core_stats.html" class="function" rel="rdfs-seeAlso">mysqlnd_qc_get_core_stats()</a> - Statistics collected by the core of the query cache</span>
    </li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>